package oceanlife.pathfinding;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class tester {

	private static HashMap<Pnt,HashMap<Pnt,Pnt>> test = new HashMap<Pnt,HashMap<Pnt,Pnt>>();
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Pnt p1 = new Pnt(0.0,1.0);
		Pnt p2 = new Pnt(4.0,3.0);
		Pnt p3 = new Pnt(6.0,-1.0);
		Pnt p4 = new Pnt(2.0,-3.0);
		
		Edge edge = new Edge(new Pnt[]{p1,p2});

		addPoint(p1);
		addPoint(p2);
		addPoint(p3);
		addPoint(p4);
		
		addEdge(p1,p2);
		addEdge(p1,p3);
		
		PointGraph testG = new PointGraph();
		testG.add(p1);
		testG.add(p2);
		testG.add(p3);
		testG.add(p4);

		testG.addEdge(p1, p2, edge);
		testG.addEdge(p1, p3, edge);
		//printGraph(testG.getTheNeighbors());
		

	}
	private static void printGraph(Map<Pnt, Map<Pnt, Pnt>> theNeighbors) {
		for(Pnt fromPnt : theNeighbors.keySet()){
			System.out.println(fromPnt.coord(0)+"/"+fromPnt.coord(1));
			for(Pnt toPnt : theNeighbors.get(fromPnt).keySet()){
				System.out.println("   "+toPnt.coord(0)+"/"+toPnt.coord(1)+" -> "+theNeighbors.get(fromPnt).get(toPnt).coord(0)+"/"+theNeighbors.get(fromPnt).get(toPnt).coord(1));
			}
			
		}

	}
	private static void addPoint(Pnt p1) {
        if (test.containsKey(p1)) return;
        test.put(p1, new HashMap<Pnt,Pnt>());
	}
	
    public static void addEdge(Pnt pA, Pnt pB) throws NullPointerException {
    	test.get(pA).put(pB,pB);
    	test.get(pB).put(pA,pA);
    }

}
